package scheduledtasks;


import org.springframework.beans.factory.annotation.Autowired;
import scheduledtasks.annotations.Scheduled;
import scheduledtasks.entity.TaskObj;
import scheduledtasks.hander.MainHander;
import scheduledtasks.hander.SpringArawaHander;
import scheduledtasks.hander.SqlHander;

import java.util.List;


/**
 * 【对外实现]
 *
 * @author tiny
 * @version 1.0
 * @company bc
 * @copyright (c) 2022 bcInc. All rights reserved.
 * @date 2022-11-08 16:00:26
 * @since
 */

public class Apiimpl implements Api {

    @Autowired
    private SqlHander sqlHander;

    @Override
    public void runScheduled(Integer id) {
       List<TaskObj> copyOnWriteArrayLists=sqlHander.connection("select * from scheduled where id="+id);
       TaskObj taskObj=new TaskObj();
        for (TaskObj t:copyOnWriteArrayLists) {
            if(t.getId()==id){
                taskObj=t;
            }
        }
        try {
            SpringArawaHander.springInvokeMethod(taskObj.getClassName(),taskObj.getMethoName(),null);
        }catch (Exception e){
             e.printStackTrace();
        }

    }


}
